package com.xunshi.hikangvision.vo.result;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;

@Data
@AllArgsConstructor
public class Result<T> implements Serializable {

    private Integer code;
    private String message;
    private T data;

    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    @AllArgsConstructor
    private enum Code {

        SUCCESS(1, "success"),
        FAIL(0, "fail");

        private Integer value;
        private String des;


    }

    public static <T> Result<T> Success(T data) {
        return new Result<>(Code.SUCCESS.value, Code.SUCCESS.des, data);
    }

    public static <T> Result<T> Fail() {
        return new Result<>(Code.FAIL.value, Code.FAIL.des);
    }

}
